Quantcast
Channel: User bdsl - Stack Overflow
Browsing latest articles
Browse All 32 View Live

Comment by bdsl on PHP class instantiation. To use or not to use the...

It's not really a function call - the constructor, if it exists, is called automatically by the system, but not directly. The return value from new is the new instance, it isn't anything returned from...

View Article



Comment by bdsl on phpunit - testing is painfully slow

It looks like Hash is a Laravel class - so only relevant if you're testing Laravel code that uses password hashing.

View Article

Comment by bdsl on How do I make a redirect in PHP?

It doesn't have to be the first statement in the code. It just has to before any output. Organise your code to do all logic before it starts printing output - then probably it should print the prepared...

View Article

Comment by bdsl on How to prevent access via reflection?

And if you are concerned about security restricting access to reflection isn't really enough on its own to be worthwhile. If the untrusted code can read, write or delete any file on the computer then...

View Article

Comment by bdsl on Is data injected into a HTTPS POST response secure from...

I think this answer misunderstands the question - and the OP may not really be understanding the situation. The Laravel merge function that the OP proposes to use is only adding data into the server...

View Article


Comment by bdsl on DDD: Should 'country' be a Value Object or an Entity?

To maybe clarify this a bit. We know that in the real world countries can change. For instance Czech Republic was renamed to Czechia. The question is does your application need to understand that that...

View Article

Comment by bdsl on How to represent hit count with Domain Driven Design

PHP typically uses a 'share-nothing' architecture, where each web request is handled in one separate thread and there is no communication between threads. So we don't hand tasks off directly to other...

View Article

Comment by bdsl on How can I handle a leap second correctly in my application

> Timestamps are just number of seconds (all seconds, doesn't matter leap or not) that pass from predefined date This isn't true. The unix timestamp explicitly excludes leap seconds. It counts only...

View Article


Comment by bdsl on PHP Unit Testing without a framework... Possible? Advisable?

@Gordon PHPUnit is itself a framework

View Article


Comment by bdsl on Theory: Compression algorithm that makes some files...

This doesn't seem remarkable - plain ascii files use only 7 bits out of every 8, so there's quite a bit of space (every 8th bit) for the file to 'grow' into without actually growing on disk.

View Article

Comment by bdsl on PHP: Best way to get a DateTimeImmutable object for a...

They're badly named, at least by current fashions. They should be wither methods instead of setter methods.

View Article

Comment by bdsl on Why is my stencil components library failing to generate a...

@AndrewF Sorry, I haven't found an answer yet.

View Article

Comment by bdsl on Is there an elegant way to have value objects in typescript?

And I see that this works even if I create another class LegalName with the same shape but a different validation rule - e.g. perhaps a LegalName has to contain a space. If I try to use one in place of...

View Article


Comment by bdsl on Why are TypeScript arrays covariant?

PHP has a built in array type that's different to anything else in the language, and they are not generally aliased. Instead a copy-on-write system is used when assigning or passing. I think it avoids...

View Article

Answer by bdsl for Passing popup link so it shows on the address bar

You can use the Javascript history API to change the address in the address bar without reloading the page. Mozilla provides instructions at https://developer.mozilla.org/en-US/docs/Web/API/History_API

View Article


How safe is it to use PhpStorm's refactoring commands

I have some PHP code that is does not have good test coverage and is not easily testable in its current state. If I use commands from the refactor menu of PhpStorm, and make no other changes, how sure...

View Article

Answer by bdsl for Should I use GET or POST when requesting sensitive data?

If the data is highly sensitive, consider using a POST. It's easy to issue a GET request without much thought - for instance if someone is looking at log file while logged in to the application with...

View Article


Answer by bdsl for How to handle config files and default settings when using...

Don't have a configuration file. Let the code which includes your project set configuration values at run time.If you are working in object oriented php you may want to take any required configuration...

View Article

Answer by bdsl for PHPUnit Mock Change the expectations later

Continue building the mock in setUp() but set the expectation separately in each test:class FooTest extends PHPUnit_Framework_TestCase { private $myservice; private $foo; public function setUp(){...

View Article

Answer by bdsl for Send email with a template using php

Create your template file, e.g,/path/to/templates/template.twig:Dear {{name}},Thank you for writing to us about {{subject}}.Then follow the instructions at https://twig.symfony.com/doc/2.x/api.html to...

View Article

Answer by bdsl for PHP Counter Using OOP

Use UpperCamelCase for class names. LogFile, not LOGFILE. When you have a variable and the most interesting thing about it is that it's expected to hold a reference to something that is_aLogFile you...

View Article


Answer by bdsl for What exactly mean by "PHP combined with MySQL are...

The point is that you may want to have more than one environment where PHP and Mysql are combined. At a minimum you probably want a Dev environment where you write the code and do initial tests, and a...

View Article


Unit testing legacy php application — how to prevent unexpected database calls

I'm adding unit tests to a legacy PHP application that uses a MySQL compatible database. I want to write genuine unit tests that don't touch the database.How should I avoid accidentally using a...

View Article

Answer by bdsl for Domain (country) realted banners in PHP based system

your idea 1) will probably work for most cases, but sometimes users will get the wrong one depending how they connect to the internet, and gives you problems with things like search engines which you...

View Article

Answer by bdsl for PSR-1 2.3 Side Effects Rule example

Yes, you may use include inside a function.As far as this rule is concerned you can do anything you want as long as inside a function. Simply executing or including a file that declares a function...

View Article


Answer by bdsl for Get only list of ID's from ManyToMany with Doctrine

I don't believe it's possible to do what you with the entities defined the way they are. The Doctrine PersistentCollection class will always initialise itself, loading all the entities from the DB when...

View Article

Answer by bdsl for Can I really do nothing with fatal parse errors?

I don't think PHP can do anything with parse errors (or other errors during the compilation phase), but you should be able to configure your web server to display an error page of your choosing.You...

View Article

Answer by bdsl for Can a function be passed as a default parameter somehow?

No, you can't call a function to provide a default argument value. As the docs put it, "The default value must be a constant expression, not (for example) a variable, a class member or a function...

View Article

Answer by bdsl for Can parameter types be specialized in PHP

The code shown in the question is not going to compile in PHP. If it did class Bar would be failing to honour the gurantee made by it's parent Foo of being able to accept any instance of TypeA, and...

View Article



How to remove commits from parent branch when rebasing?

Suppose I have a branch widget, which was made by branching off feature and adding several commits about building the widget.I now want the widget to be available in master, without the rest of the...

View Article

Answer by bdsl for Can you override interface methods with different, but...

PHP 7.4, released November 2019 has improved type variance.The code from the question remains invalid:interface Item { // some methods here}interface SuperItem extends Item { // some extra methods...

View Article

Answer by bdsl for How to call a PHP function within a function when the main...

If you return a value from the myMenu function, you can assign it to a variable in the myPage function. Something like this:function myMenu() { return "menu";}function myPage() { $content = myMenu();...

View Article
Browsing latest articles
Browse All 32 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>